import time
import threading#导入线程模块
def singing(name,age=18,score=100):
    for i in range(5):
        print(f"{name},{age},{score}La la la...",i)
        time.sleep(0.5)
def dancing(name,age=18,score=100):
    for i in range(5):
        print(f"{name},{age},{score}Dancing...",i)
        time.sleep(0.5)
if __name__ == "__main__":
    t1=threading.Thread(target=singing,args=("Alice",25,90))#将任务交给线程，可以kwargs传入字典
    t2=threading.Thread(target=dancing,args=("Bob",30,85))
    t1.daemon=True  # 设置为守护线程
    t2.daemon=True  # 设置为守护线程,全设置为守护线程才在主程序退出时自动退出；应该在start之前设置
    t1.start()
    t2.start()#线程创建和起的不会阻塞当前线程
    time.sleep(1)
    print("主线程结束")